package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("permissions/project")
public @caption("项目菜单") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("srv_project") class SrvProject implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
	private @caption("编号") @column("sp_id")    @primary  @notnull  @note("  ") Long spId;// 主键 非空     
	private @caption("项目名称") @column("sp_name")     @notnull  @note("  ") String spName;// 非空     
	private @caption("父节点") @column("sp_parent_id")     @notnull  @relate("$spParentId") @RelateClass(SrvProject.class)  @note("  ") Long spParentId;// 非空     
 	private transient SrvProject $spParentId;//关联对象[项目菜单]
	private @caption("家族") @column("sp_family")      @note("  ") String spFamily;//     
	private @caption("标识") @column("sp_flag") @like     @note("  ") String spFlag;//     
	private @caption("项目地址") @column("sp_url")     @notnull  @note("  ") String spUrl;// 非空     
	private @caption("Logo") @column("sp_logo")      @note("  ") String spLogo;//     
	private @caption("项目描述") @column("sp_descript")      @note("  ") String spDescript;//     
	private @caption("优先级") @column("sp_level")      @note("  ") Integer spLevel;//     
	private @caption("扩展权限") @column("sp_limit_exp") @like     @note("  ") String spLimitExp;//     
	private @caption("项目分组") @column("sp_group")      @note("  ") String spGroup;//     
	private @caption("流程信息") @column("sp_mind") @like     @note("  ") String spMind;//     
	private @caption("状态") @column("sp_status")     @notnull  @note(" 1:有效 0:无效  ") Short spStatus;// 非空 1:有效 0:无效     
	 
	//默认构造函数
	public SrvProject(){ 
	
	}
	
	//主键构造函数
	public SrvProject(Long id){
		this.spId = id;
	}
	
	/**所有字段构造函数 
	 SrvProject(
	 	Utils.getString("spName")//项目名称 [非空]
	 	,Utils.getLong("spParentId")//父节点 [非空]
	 	,Utils.getString("spFamily")//家族
	 	,Utils.getString("spFlag")//标识
	 	,Utils.getString("spUrl")//项目地址 [非空]
	 	,Utils.getString("spLogo")//Logo
	 	,Utils.getString("spDescript")//项目描述
	 	,Utils.getInteger("spLevel")//优先级
	 	,Utils.getString("spLimitExp")//扩展权限
	 	,Utils.getString("spGroup")//项目分组
	 	,Utils.getString("spMind")//流程信息
	 	,Utils.getShort("spStatus")//状态 [非空]
	 )
	**/
	public SrvProject(String spName,Long spParentId,String spFamily,String spFlag,String spUrl,String spLogo,String spDescript,Integer spLevel,String spLimitExp,String spGroup,String spMind,Short spStatus){
		this.spName=spName;
		this.spParentId=spParentId;
		this.spFamily=spFamily;
		this.spFlag=spFlag;
		this.spUrl=spUrl;
		this.spLogo=spLogo;
		this.spDescript=spDescript;
		this.spLevel=spLevel;
		this.spLimitExp=spLimitExp;
		this.spGroup=spGroup;
		this.spMind=spMind;
		this.spStatus=spStatus;
	}
	
	//设置非空字段
	public SrvProject setNotNull(String spName,Long spParentId,String spUrl,Short spStatus){
		this.spName=spName;
		this.spParentId=spParentId;
		this.spUrl=spUrl;
		this.spStatus=spStatus;
		return this;
	}
	/** 编号 [非空]       **/
	public SrvProject spId(Long spId){
		this.spId = spId;
		this.setSeted(F.spId);
		return this;
	}
	/** 项目名称 [非空]       **/
	public SrvProject spName(String spName){
		this.spName = spName;
		this.setSeted(F.spName);
		return this;
	}
	/** 父节点 [非空] [SrvProject]      **/
	public SrvProject spParentId(Long spParentId){
		this.spParentId = spParentId;
		this.setSeted(F.spParentId);
		return this;
	}
	/** 家族        **/
	public SrvProject spFamily(String spFamily){
		this.spFamily = spFamily;
		this.setSeted(F.spFamily);
		return this;
	}
	/** 标识        **/
	public SrvProject spFlag(String spFlag){
		this.spFlag = spFlag;
		this.setSeted(F.spFlag);
		return this;
	}
	/** 项目地址 [非空]       **/
	public SrvProject spUrl(String spUrl){
		this.spUrl = spUrl;
		this.setSeted(F.spUrl);
		return this;
	}
	/** Logo        **/
	public SrvProject spLogo(String spLogo){
		this.spLogo = spLogo;
		this.setSeted(F.spLogo);
		return this;
	}
	/** 项目描述        **/
	public SrvProject spDescript(String spDescript){
		this.spDescript = spDescript;
		this.setSeted(F.spDescript);
		return this;
	}
	/** 优先级        **/
	public SrvProject spLevel(Integer spLevel){
		this.spLevel = spLevel;
		this.setSeted(F.spLevel);
		return this;
	}
	/** 扩展权限        **/
	public SrvProject spLimitExp(String spLimitExp){
		this.spLimitExp = spLimitExp;
		this.setSeted(F.spLimitExp);
		return this;
	}
	/** 项目分组        **/
	public SrvProject spGroup(String spGroup){
		this.spGroup = spGroup;
		this.setSeted(F.spGroup);
		return this;
	}
	/** 流程信息        **/
	public SrvProject spMind(String spMind){
		this.spMind = spMind;
		this.setSeted(F.spMind);
		return this;
	}
	/** 状态 [非空]   1:有效 0:无效     **/
	public SrvProject spStatus(Short spStatus){
		this.spStatus = spStatus;
		this.setSeted(F.spStatus);
		return this;
	}
	
	
	/**
	* 克隆对象
	**/
	public SrvProject clone(){
		SrvProject clone = new SrvProject();
		clone.spName=this.spName;
		clone.spParentId=this.spParentId;
		clone.spFamily=this.spFamily;
		clone.spFlag=this.spFlag;
		clone.spUrl=this.spUrl;
		clone.spLogo=this.spLogo;
		clone.spDescript=this.spDescript;
		clone.spLevel=this.spLevel;
		clone.spLimitExp=this.spLimitExp;
		clone.spGroup=this.spGroup;
		clone.spMind=this.spMind;
		clone.spStatus=this.spStatus;
		return clone;
	}
	/**
	* 清除缓存
	**/
	public void clear(){
		Cache.clearObject(SrvProject.M.class);
		Cache.clearValue(SrvProject.M.class);
		Cache.deleteObject(SrvProject.class, this.getId());
	}
	
	/**
	* 清除缓存
	**/
	public static void clear(Long id){
		Cache.clearObject(SrvProject.M.class);
		Cache.clearValue(SrvProject.M.class);
		Cache.deleteObject(SrvProject.class, id);
	}
	
	
	/**
	 * 根据ID取项目菜单
	 * @param id
	 * @return
	 */
	public static @api SrvProject get(Long id){		
		return getSrvProjectById(id);
	}
	/**
	 * 设置ID
	 * @param id
	 * @return
	 */
	public void setId(Long id){		
		this.spId = id;
	}
	
	/**
	 * 获取所有项目菜单
	 * @return
	 */
	public static @api List<SrvProject> list(Map params,Integer size){
		return getSrvProjectList(params,size);
	}
	/**
	 * 获取项目菜单分页
	 * @return
	 */
	public static @api Page<SrvProject> page(Integer page,Integer size,Map params){
		return getSrvProjectPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取项目菜单
	 * @param params
	 * @return
	 */
	public static @api SrvProject Get(Map params){
		return getSrvProject(params);
	}
	/**
	 * 获取项目菜单数
	 * @return
	 */
	public static @api Long count(Map params){
		return getSrvProjectCount(params);
	}
	/**
	 * 获取项目菜单数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getSrvProjectEval(eval,params);
	}
	/**
	 * 获取项目菜单图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getSrvProjectStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取项目菜单图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getSrvProjectStats(params,sumKey,groupKey,dateType);
	}
	
	/**
	 * 根据ID取项目菜单
	 * @param id
	 * @return
	 */
	public static @api SrvProject getSrvProjectById(Long id){		
		return getSrvProjectDao().getSrvProjectById(id);
	}
	/**
	 * 获取id
	 * @return
	 */
	public Long getId(){
		return this.spId;
	}
	
	
	/**
	 * 根据ID取项目菜单的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			return "[无]";
		}
		String value = null;
		value = Cache.getValue(SrvProject.class, id);
		if(value==null){
			SrvProject srvProject = get(id);
			if(srvProject!=null){
				String strValue = srvProject.getSpName$();
				if(!"SpName".equals("SpName"))
					strValue+="("+srvProject.getSpName$()+")";
				Cache.setValue(SrvProject.class, id ,strValue);
				value = strValue;
			}else{
				Cache.setValue(SrvProject.class, id ,"{"+id+"}",30);
				value = "{"+id+"}";
			}
		}
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getSpName$();
		if(!"SpName".equals("SpName"))
			keyValue+="("+this.getSpName$()+")";
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询项目菜单对象
	 * @return
	 */
	public static @api SrvProject find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("spId", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			strDefinex+=" or sp_name = '"+key.replaceAll("'", "''")+"'";
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return SrvProject.getSrvProject(params);
	}
	
	
	/**
	 * 根据关键字查询项目菜单
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","sp_id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("spId", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				strDefinex+=" or sp_name like '%"+strTerm.replaceAll("'", "''")+"%'";
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<SrvProject> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(SrvProject srvProject:list){
			Map map = new HashMap();
			map.put("key",srvProject.getSpId().toString());
			map.put("value", Utils.js(srvProject.getKeyValue()));
			if(bObject==true)
				map.put("object",srvProject);
			result.add(map);
		}
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有项目菜单
	 * @return
	 */
	public static @api List<SrvProject> getSrvProjectList(Map params,Integer size){
		return getSrvProjectDao().getSrvProjectList(params,0,size);
	}
	
	/**
	 * 获取项目菜单分页
	 * @return
	 */
	public static @api Page<SrvProject> getSrvProjectPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getSrvProjectDao().getSrvProjectPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取项目菜单
	 * @param params
	 * @return
	 */
	public static @api SrvProject getSrvProject(Map params){
		return getSrvProjectDao().getSrvProject(params);
	}
	
	/**
	 * 保存一个项目菜单
	 * @param srvProject
	 * @return
	 */
	public static @api SrvProject saveSrvProject(SrvProject srvProject){
		return getSrvProjectDao().saveSrvProject(srvProject);
	}
	
	/**
	 * 根据条件更新项目菜单
	 * @param values
	 * @param params
	 */
	public static @api int updateSrvProjectByConfirm(Map values, Map params){
		return getSrvProjectDao().updateSrvProjectByConfirm(values,params);
	}
	
	/**
	 * 修改一个项目菜单
	 * @param srvProject
	 * @return
	 */
	public static @api int updateSrvProject(SrvProject srvProject){
		return getSrvProjectDao().updateSrvProject(srvProject);
	}
	
	/**
	 * 更新项目菜单非空字段
	 * @param srvProject
	 */
	public static @api int updateSrvProject$NotNull(SrvProject srvProject){
		return getSrvProjectDao().updateSrvProject$NotNull(srvProject);
	}
	
	/**
	 * 获取项目菜单数
	 * @return
	 */
	public static @api Long getSrvProjectCount(Map params){
		return getSrvProjectDao().getSrvProjectCount(params);
	}
		
		
	/**
	 * 获取项目菜单自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getSrvProjectEval(String eval,Map params){
		return getSrvProjectDao().getSrvProjectEval(eval,params);
	}
	/**
	 * 获取项目菜单图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getSrvProjectStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getSrvProjectDao().getSrvProjectStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = SrvProject.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(SrvProject.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateSrvProject(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getSrvProjectDao().updateSrvProjectByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteSrvProject(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getSrvProjectDao().deleteSrvProjectByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		getSrvProjectDao().deleteSrvProjectById(id);
	}
	
	
	/**
	 * 保存项目菜单对象
	 * @param params
	 * @return
	 */
	public SrvProject save(){
		if(this.getSpId()!=null)
			getSrvProjectDao().updateSrvProject(this);
		else
			return getSrvProjectDao().saveSrvProject(this);
		return this;
	}
	
	
	/**
	 * 更新项目菜单对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getSrvProjectDao().updateSrvProject$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
			getSrvProjectDao().deleteSrvProjectById(this.getSpId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getSrvProjectDao().executeTransaction(function);
	}
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getSpId(){
		if(this.spId!=null){
			return this.spId;
		}
		return this.spId;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getSpId$(){
		String strValue="";
		 strValue=Utils.string(this.getSpId());
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setSpId$(String strValue){
		if(Utils.empty(strValue)){
			this.spId=null;
			return;
		}
	 	this.spId=Utils.parseLong(strValue);
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setSpId(Long spId){
		this.spId = spId;
		this.setSeted(F.spId);
	}
	
	
	
	
	/*******************************项目名称**********************************/	
	/**
	* 项目名称 [非空]      
	**/
	public String getSpName(){
		if(this.spName!=null){
			return this.spName;
		}
		return this.spName;
	}
	/**
	* 获取项目名称格式化(toString)
	**/
	public String getSpName$(){
		String strValue="";
		 strValue=Utils.string(this.getSpName());
	 	 return strValue;
	}
	/**
	* 根据项目名称反格式化
	**/
	public void setSpName$(String strValue){
		if(Utils.empty(strValue)){
			this.spName=null;
			return;
		}
	 	this.spName=strValue;
	}
	
	/**
	* 项目名称 [非空]      
	**/
	public void setSpName(String spName){
		this.spName = spName;
		this.setSeted(F.spName);
	}
	
	
	
	
	/*******************************父节点**********************************/	
	/**
	* 父节点 [非空] [SrvProject]     
	**/
	public Long getSpParentId(){
		if(this.spParentId!=null){
			return this.spParentId;
		}
		return this.spParentId;
	}
	/**
	* 获取父节点格式化(toString)
	**/
	public String getSpParentId$(){
		String strValue="";
		if(this.getSpParentId()!=null){
				strValue+=Utils.string(SrvProject.getKeyValue(this.getSpParentId()));
		}			
	 	 return strValue;
	}
	/**
	* 根据父节点反格式化
	**/
	public void setSpParentId$(String strValue){
		if(Utils.empty(strValue)){
			this.spParentId=null;
			return;
		}
		SrvProject item = SrvProject.find(strValue);
		if(item!=null){
			this.spParentId = Utils.parseLong(item.getSpId());
		}
	}
	
	/**
	* 父节点 [非空] [SrvProject]     
	**/
	public void setSpParentId(Long spParentId){
		this.spParentId = spParentId;
		this.setSeted(F.spParentId);
	}
	
	
	
	
	/**
	* 获取关联对象[项目菜单]
	**/	 			
 	public SrvProject get$spParentId(){
 		if(this.$spParentId!=null)
 			return this.$spParentId;
 		com.distribute.framework.model.SrvProject srvProject = null;
		if(this.getSpParentId()!=null){
 			srvProject = SrvProject.get(this.getSpParentId());
 		}
 		return srvProject;
	}
	/*******************************家族**********************************/	
	/**
	* 家族       
	**/
	public String getSpFamily(){
		if(this.spFamily!=null){
			return this.spFamily;
		}
		return this.spFamily;
	}
	/**
	* 获取家族格式化(toString)
	**/
	public String getSpFamily$(){
		String strValue="";
		 strValue=Utils.string(this.getSpFamily());	
	 	 return strValue;
	}
	/**
	* 根据家族反格式化
	**/
	public void setSpFamily$(String strValue){
		if(Utils.empty(strValue)){
			this.spFamily=null;
			return;
		}
		 //此处未实现
		 this.spFamily=Utils.parseString(strValue);
	}
	
	/**
	* 家族       
	**/
	public void setSpFamily(String spFamily){
		this.spFamily = spFamily;
		this.setSeted(F.spFamily);
	}
	
	
	
	
	/*******************************标识**********************************/	
	/**
	* 标识       
	**/
	public String getSpFlag(){
		if(this.spFlag!=null){
			return this.spFlag;
		}
		return this.spFlag;
	}
	/**
	* 获取标识格式化(toString)
	**/
	public String getSpFlag$(){
		String strValue="";
		 strValue=Utils.string(this.getSpFlag());
	 	 return strValue;
	}
	/**
	* 根据标识反格式化
	**/
	public void setSpFlag$(String strValue){
		if(Utils.empty(strValue)){
			this.spFlag=null;
			return;
		}
	 	this.spFlag=strValue;
	}
	
	/**
	* 标识       
	**/
	public void setSpFlag(String spFlag){
		this.spFlag = spFlag;
		this.setSeted(F.spFlag);
	}
	
	
	
	
	/*******************************项目地址**********************************/	
	/**
	* 项目地址 [非空]      
	**/
	public String getSpUrl(){
		if(this.spUrl!=null){
			return this.spUrl;
		}
		return this.spUrl;
	}
	/**
	* 获取项目地址格式化(toString)
	**/
	public String getSpUrl$(){
		String strValue="";
		 strValue=Utils.string(this.getSpUrl());
	 	 return strValue;
	}
	/**
	* 根据项目地址反格式化
	**/
	public void setSpUrl$(String strValue){
		if(Utils.empty(strValue)){
			this.spUrl=null;
			return;
		}
	 	this.spUrl=strValue;
	}
	
	/**
	* 项目地址 [非空]      
	**/
	public void setSpUrl(String spUrl){
		this.spUrl = spUrl;
		this.setSeted(F.spUrl);
	}
	
	
	
	
	/*******************************Logo**********************************/	
	/**
	* Logo       
	**/
	public String getSpLogo(){
		if(this.spLogo!=null){
			return this.spLogo;
		}
		return this.spLogo;
	}
	/**
	* 获取Logo格式化(toString)
	**/
	public String getSpLogo$(){
		String strValue="";
		 strValue=Utils.string(this.getSpLogo());
	 	 return strValue;
	}
	/**
	* 根据Logo反格式化
	**/
	public void setSpLogo$(String strValue){
		if(Utils.empty(strValue)){
			this.spLogo=null;
			return;
		}
		this.spLogo=Utils.parseString(strValue);
	}
	
	/**
	* Logo       
	**/
	public void setSpLogo(String spLogo){
		this.spLogo = spLogo;
		this.setSeted(F.spLogo);
	}
	
	
	
	
	/*******************************项目描述**********************************/	
	/**
	* 项目描述       
	**/
	public String getSpDescript(){
		if(this.spDescript!=null){
			return this.spDescript;
		}
		return this.spDescript;
	}
	/**
	* 获取项目描述格式化(toString)
	**/
	public String getSpDescript$(){
		String strValue="";
		 strValue=Utils.string(this.getSpDescript());
	 	 return strValue;
	}
	/**
	* 根据项目描述反格式化
	**/
	public void setSpDescript$(String strValue){
		if(Utils.empty(strValue)){
			this.spDescript=null;
			return;
		}
	 	this.spDescript=strValue;
	}
	
	/**
	* 项目描述       
	**/
	public void setSpDescript(String spDescript){
		this.spDescript = spDescript;
		this.setSeted(F.spDescript);
	}
	
	
	
	
	/*******************************优先级**********************************/	
	/**
	* 优先级       
	**/
	public Integer getSpLevel(){
		if(this.spLevel!=null){
			return this.spLevel;
		}
		return this.spLevel;
	}
	/**
	* 获取优先级格式化(toString)
	**/
	public String getSpLevel$(){
		String strValue="";
		 strValue=Utils.string(this.getSpLevel());
	 	 return strValue;
	}
	/**
	* 根据优先级反格式化
	**/
	public void setSpLevel$(String strValue){
		if(Utils.empty(strValue)){
			this.spLevel=null;
			return;
		}
	 	this.spLevel=Utils.parseInteger(strValue);
	}
	
	/**
	* 优先级       
	**/
	public void setSpLevel(Integer spLevel){
		this.spLevel = spLevel;
		this.setSeted(F.spLevel);
	}
	
	
	
	
	/*******************************扩展权限**********************************/	
	/**
	* 扩展权限       
	**/
	public String getSpLimitExp(){
		if(this.spLimitExp!=null){
			return this.spLimitExp;
		}
		return this.spLimitExp;
	}
	/**
	* 获取扩展权限格式化(toString)
	**/
	public String getSpLimitExp$(){
		String strValue="";
		 strValue=Utils.string(this.getSpLimitExp());
	 	 return strValue;
	}
	/**
	* 根据扩展权限反格式化
	**/
	public void setSpLimitExp$(String strValue){
		if(Utils.empty(strValue)){
			this.spLimitExp=null;
			return;
		}
	 	this.spLimitExp=strValue;
	}
	
	/**
	* 扩展权限       
	**/
	public void setSpLimitExp(String spLimitExp){
		this.spLimitExp = spLimitExp;
		this.setSeted(F.spLimitExp);
	}
	
	
	
	
	/*******************************项目分组**********************************/	
	/**
	* 项目分组       
	**/
	public String getSpGroup(){
		if(this.spGroup!=null){
			return this.spGroup;
		}
		return this.spGroup;
	}
	/**
	* 获取项目分组格式化(toString)
	**/
	public String getSpGroup$(){
		String strValue="";
		 strValue=Utils.string(this.getSpGroup());
	 	 return strValue;
	}
	/**
	* 根据项目分组反格式化
	**/
	public void setSpGroup$(String strValue){
		if(Utils.empty(strValue)){
			this.spGroup=null;
			return;
		}
	 	this.spGroup=strValue;
	}
	
	/**
	* 项目分组       
	**/
	public void setSpGroup(String spGroup){
		this.spGroup = spGroup;
		this.setSeted(F.spGroup);
	}
	
	
	
	
	/*******************************流程信息**********************************/	
	/**
	* 流程信息       
	**/
	public String getSpMind(){
		if(this.spMind!=null){
			return this.spMind;
		}
		return this.spMind;
	}
	/**
	* 获取流程信息格式化(toString)
	**/
	public String getSpMind$(){
		String strValue="";
		 strValue=Utils.string(this.getSpMind());
	 	 return strValue;
	}
	/**
	* 根据流程信息反格式化
	**/
	public void setSpMind$(String strValue){
		if(Utils.empty(strValue)){
			this.spMind=null;
			return;
		}
		this.spMind=strValue;
	}
	
	/**
	* 流程信息       
	**/
	public void setSpMind(String spMind){
		this.spMind = spMind;
		this.setSeted(F.spMind);
	}
	
	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   1:有效 0:无效    
	**/
	public Short getSpStatus(){
		if(this.spStatus!=null){
			return this.spStatus;
		}
		return this.spStatus;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getSpStatus$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSpStatus()),"1"))
			strValue=Utils.string("有效");		 
		 if(Utils.equals(Utils.string(this.getSpStatus()),"0"))
			strValue=Utils.string("无效");		 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setSpStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.spStatus=null;
			return;
		}
		 if(Utils.equals(strValue,"有效"))
		 	this.spStatus=Utils.parseShort("1");
		 if(Utils.equals(strValue,"无效"))
		 	this.spStatus=Utils.parseShort("0");
	}
	
	/**
	* 状态 [非空]   1:有效 0:无效    
	**/
	public void setSpStatus(Short spStatus){
		this.spStatus = spStatus;
		this.setSeted(F.spStatus);
	}
	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(SrvProject.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(SrvProject.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(SrvProject.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(SrvProject.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(SrvProject.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${SrvProject.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvProject.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvProject.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(SrvProject.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${SrvProject.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvProject.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvProject.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(SrvProject.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		/** 编号 [非空]       **/
		public M spId(Object spId){if(proxy)return proxy().spId(spId);  this.put("spId", spId);return this;};
	 	/** and sp_id is null */
 		public M spIdNull(){if(proxy)return proxy().spIdNull();if(this.get("spIdNot")==null)this.put("spIdNot", "");this.put("spId", null);return this;};
 		/** not .... */
 		public M spIdNot(){if(proxy)return proxy().spIdNot();this.put("spIdNot", "not");return this;};
 		public M spIdNotNull(){if(proxy)return proxy().spIdNotNull();this.put("spIdNot", "not");this.put("spId", null);return this;};
 		public M spIdNot(Object spId){if(proxy)return proxy().spIdNot(spId);this.put("spIdNot", "not");this.put("spId", spId);return this;};
		/** and sp_id <= ? */
		public M spIdMin(Object min){if(proxy)return proxy().spIdMin(min);this.put("spIdMin", min);return this;};
		/** and sp_id >= ? */
		public M spIdMax(Object max){if(proxy)return proxy().spIdMax(max);this.put("spIdMax", max);return this;};
		public M spIdIn(String ids){
			if(proxy)return proxy().spIdIn(ids);  this.put("spIdIn", ids);return this;
		};	
		/** 项目名称 [非空]       **/
		public M spName(Object spName){if(proxy)return proxy().spName(spName);  this.put("spName", spName);return this;};
	 	/** and sp_name is null */
 		public M spNameNull(){if(proxy)return proxy().spNameNull();if(this.get("spNameNot")==null)this.put("spNameNot", "");this.put("spName", null);return this;};
 		/** not .... */
 		public M spNameNot(){if(proxy)return proxy().spNameNot();this.put("spNameNot", "not");return this;};
 		public M spNameNotNull(){if(proxy)return proxy().spNameNotNull();this.put("spNameNot", "not");this.put("spName", null);return this;};
 		public M spNameNot(Object spName){if(proxy)return proxy().spNameNot(spName);this.put("spNameNot", "not");this.put("spName", spName);return this;};
		public M spParentId$on(SrvProject.M value){if(proxy)return proxy().spParentId$on(value);this.put("SpParentId", value);value.put("on", "sp_parent_id");return this;};
		/** 父节点 [非空] [SrvProject]      **/
		public M spParentId(Object spParentId){if(proxy)return proxy().spParentId(spParentId);  this.put("spParentId", spParentId);return this;};
	 	/** and sp_parent_id is null */
 		public M spParentIdNull(){if(proxy)return proxy().spParentIdNull();if(this.get("spParentIdNot")==null)this.put("spParentIdNot", "");this.put("spParentId", null);return this;};
 		/** not .... */
 		public M spParentIdNot(){if(proxy)return proxy().spParentIdNot();this.put("spParentIdNot", "not");return this;};
 		public M spParentIdNotNull(){if(proxy)return proxy().spParentIdNotNull();this.put("spParentIdNot", "not");this.put("spParentId", null);return this;};
 		public M spParentIdNot(Object spParentId){if(proxy)return proxy().spParentIdNot(spParentId);this.put("spParentIdNot", "not");this.put("spParentId", spParentId);return this;};
		public M spParentIdIn(String ids){
			if(proxy)return proxy().spParentIdIn(ids);  this.put("spParentIdIn", ids);return this;
		};	
		/** 家族        **/
		public M spFamily(Object spFamily){if(proxy)return proxy().spFamily(spFamily);  this.put("spFamily", spFamily);return this;};
	 	/** and sp_family is null */
 		public M spFamilyNull(){if(proxy)return proxy().spFamilyNull();if(this.get("spFamilyNot")==null)this.put("spFamilyNot", "");this.put("spFamily", null);return this;};
 		/** not .... */
 		public M spFamilyNot(){if(proxy)return proxy().spFamilyNot();this.put("spFamilyNot", "not");return this;};
 		public M spFamilyNotNull(){if(proxy)return proxy().spFamilyNotNull();this.put("spFamilyNot", "not");this.put("spFamily", null);return this;};
 		public M spFamilyNot(Object spFamily){if(proxy)return proxy().spFamilyNot(spFamily);this.put("spFamilyNot", "not");this.put("spFamily", spFamily);return this;};
		/** 标识        **/
		public M spFlag(Object spFlag){if(proxy)return proxy().spFlag(spFlag);  this.put("spFlag", spFlag);return this;};
	 	/** and sp_flag is null */
 		public M spFlagNull(){if(proxy)return proxy().spFlagNull();if(this.get("spFlagNot")==null)this.put("spFlagNot", "");this.put("spFlag", null);return this;};
 		/** not .... */
 		public M spFlagNot(){if(proxy)return proxy().spFlagNot();this.put("spFlagNot", "not");return this;};
 		public M spFlagNotNull(){if(proxy)return proxy().spFlagNotNull();this.put("spFlagNot", "not");this.put("spFlag", null);return this;};
 		public M spFlagNot(Object spFlag){if(proxy)return proxy().spFlagNot(spFlag);this.put("spFlagNot", "not");this.put("spFlag", spFlag);return this;};
		/** 项目地址 [非空]       **/
		public M spUrl(Object spUrl){if(proxy)return proxy().spUrl(spUrl);  this.put("spUrl", spUrl);return this;};
	 	/** and sp_url is null */
 		public M spUrlNull(){if(proxy)return proxy().spUrlNull();if(this.get("spUrlNot")==null)this.put("spUrlNot", "");this.put("spUrl", null);return this;};
 		/** not .... */
 		public M spUrlNot(){if(proxy)return proxy().spUrlNot();this.put("spUrlNot", "not");return this;};
 		public M spUrlNotNull(){if(proxy)return proxy().spUrlNotNull();this.put("spUrlNot", "not");this.put("spUrl", null);return this;};
 		public M spUrlNot(Object spUrl){if(proxy)return proxy().spUrlNot(spUrl);this.put("spUrlNot", "not");this.put("spUrl", spUrl);return this;};
		/** Logo        **/
		public M spLogo(Object spLogo){if(proxy)return proxy().spLogo(spLogo);  this.put("spLogo", spLogo);return this;};
	 	/** and sp_logo is null */
 		public M spLogoNull(){if(proxy)return proxy().spLogoNull();if(this.get("spLogoNot")==null)this.put("spLogoNot", "");this.put("spLogo", null);return this;};
 		/** not .... */
 		public M spLogoNot(){if(proxy)return proxy().spLogoNot();this.put("spLogoNot", "not");return this;};
 		public M spLogoNotNull(){if(proxy)return proxy().spLogoNotNull();this.put("spLogoNot", "not");this.put("spLogo", null);return this;};
 		public M spLogoNot(Object spLogo){if(proxy)return proxy().spLogoNot(spLogo);this.put("spLogoNot", "not");this.put("spLogo", spLogo);return this;};
		/** 项目描述        **/
		public M spDescript(Object spDescript){if(proxy)return proxy().spDescript(spDescript);  this.put("spDescript", spDescript);return this;};
	 	/** and sp_descript is null */
 		public M spDescriptNull(){if(proxy)return proxy().spDescriptNull();if(this.get("spDescriptNot")==null)this.put("spDescriptNot", "");this.put("spDescript", null);return this;};
 		/** not .... */
 		public M spDescriptNot(){if(proxy)return proxy().spDescriptNot();this.put("spDescriptNot", "not");return this;};
 		public M spDescriptNotNull(){if(proxy)return proxy().spDescriptNotNull();this.put("spDescriptNot", "not");this.put("spDescript", null);return this;};
 		public M spDescriptNot(Object spDescript){if(proxy)return proxy().spDescriptNot(spDescript);this.put("spDescriptNot", "not");this.put("spDescript", spDescript);return this;};
		/** 优先级        **/
		public M spLevel(Object spLevel){if(proxy)return proxy().spLevel(spLevel);  this.put("spLevel", spLevel);return this;};
	 	/** and sp_level is null */
 		public M spLevelNull(){if(proxy)return proxy().spLevelNull();if(this.get("spLevelNot")==null)this.put("spLevelNot", "");this.put("spLevel", null);return this;};
 		/** not .... */
 		public M spLevelNot(){if(proxy)return proxy().spLevelNot();this.put("spLevelNot", "not");return this;};
 		public M spLevelNotNull(){if(proxy)return proxy().spLevelNotNull();this.put("spLevelNot", "not");this.put("spLevel", null);return this;};
 		public M spLevelNot(Object spLevel){if(proxy)return proxy().spLevelNot(spLevel);this.put("spLevelNot", "not");this.put("spLevel", spLevel);return this;};
		/** and sp_level <= ? */
		public M spLevelMin(Object min){if(proxy)return proxy().spLevelMin(min);this.put("spLevelMin", min);return this;};
		/** and sp_level >= ? */
		public M spLevelMax(Object max){if(proxy)return proxy().spLevelMax(max);this.put("spLevelMax", max);return this;};
		public M spLevelIn(String ids){
			if(proxy)return proxy().spLevelIn(ids);  this.put("spLevelIn", ids);return this;
		};	
		/** 扩展权限        **/
		public M spLimitExp(Object spLimitExp){if(proxy)return proxy().spLimitExp(spLimitExp);  this.put("spLimitExp", spLimitExp);return this;};
	 	/** and sp_limit_exp is null */
 		public M spLimitExpNull(){if(proxy)return proxy().spLimitExpNull();if(this.get("spLimitExpNot")==null)this.put("spLimitExpNot", "");this.put("spLimitExp", null);return this;};
 		/** not .... */
 		public M spLimitExpNot(){if(proxy)return proxy().spLimitExpNot();this.put("spLimitExpNot", "not");return this;};
 		public M spLimitExpNotNull(){if(proxy)return proxy().spLimitExpNotNull();this.put("spLimitExpNot", "not");this.put("spLimitExp", null);return this;};
 		public M spLimitExpNot(Object spLimitExp){if(proxy)return proxy().spLimitExpNot(spLimitExp);this.put("spLimitExpNot", "not");this.put("spLimitExp", spLimitExp);return this;};
		/** 项目分组        **/
		public M spGroup(Object spGroup){if(proxy)return proxy().spGroup(spGroup);  this.put("spGroup", spGroup);return this;};
	 	/** and sp_group is null */
 		public M spGroupNull(){if(proxy)return proxy().spGroupNull();if(this.get("spGroupNot")==null)this.put("spGroupNot", "");this.put("spGroup", null);return this;};
 		/** not .... */
 		public M spGroupNot(){if(proxy)return proxy().spGroupNot();this.put("spGroupNot", "not");return this;};
 		public M spGroupNotNull(){if(proxy)return proxy().spGroupNotNull();this.put("spGroupNot", "not");this.put("spGroup", null);return this;};
 		public M spGroupNot(Object spGroup){if(proxy)return proxy().spGroupNot(spGroup);this.put("spGroupNot", "not");this.put("spGroup", spGroup);return this;};
		/** 流程信息        **/
		public M spMind(Object spMind){if(proxy)return proxy().spMind(spMind);  this.put("spMind", spMind);return this;};
	 	/** and sp_mind is null */
 		public M spMindNull(){if(proxy)return proxy().spMindNull();if(this.get("spMindNot")==null)this.put("spMindNot", "");this.put("spMind", null);return this;};
 		/** not .... */
 		public M spMindNot(){if(proxy)return proxy().spMindNot();this.put("spMindNot", "not");return this;};
 		public M spMindNotNull(){if(proxy)return proxy().spMindNotNull();this.put("spMindNot", "not");this.put("spMind", null);return this;};
 		public M spMindNot(Object spMind){if(proxy)return proxy().spMindNot(spMind);this.put("spMindNot", "not");this.put("spMind", spMind);return this;};
		/** 状态 [非空]   1:有效 0:无效     **/
		public M spStatus(Object spStatus){if(proxy)return proxy().spStatus(spStatus);  this.put("spStatus", spStatus);return this;};
	 	/** and sp_status is null */
 		public M spStatusNull(){if(proxy)return proxy().spStatusNull();if(this.get("spStatusNot")==null)this.put("spStatusNot", "");this.put("spStatus", null);return this;};
 		/** not .... */
 		public M spStatusNot(){if(proxy)return proxy().spStatusNot();this.put("spStatusNot", "not");return this;};
 		public M spStatusNotNull(){if(proxy)return proxy().spStatusNotNull();this.put("spStatusNot", "not");this.put("spStatus", null);return this;};
 		public M spStatusNot(Object spStatus){if(proxy)return proxy().spStatusNot(spStatus);this.put("spStatusNot", "not");this.put("spStatus", spStatus);return this;};
		public M spStatusIn(String ids){
			if(proxy)return proxy().spStatusIn(ids);  this.put("spStatusIn", ids);return this;
		};	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	/** 获取所有项目菜单 **/
		public @api List<SrvProject> list(Integer size){			
			return getSrvProjectList(this,size);
		}
		/** 获取项目菜单分页 **/
		public @api Page<SrvProject> page(Integer page,Integer size){			
			return getSrvProjectPage(page, size , this);
		}
		/** 根据查询条件取项目菜单 **/
		public @api SrvProject get(){			
			return getSrvProject(this);
		}
		/** 获取项目菜单数 **/
		public @api Long count(){			
			return getSrvProjectCount(this);
		}
		/** 获取项目菜单表达式 **/
		public @api <T> T eval(String strEval){			
			return getSrvProjectEval(strEval,this);
		}
		/** 获取项目菜单统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getSrvProjectStats(this,sumKey,groupKey,dateType);
		}
		/** 获取项目菜单统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getSrvProjectStats(this,sumKey,groupKey,-1);
		}
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateSrvProject(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteSrvProject(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String spId="spId";
		/** 项目名称 [非空]       **/
		public final static @type(String.class)  String spName="spName";
		/** 父节点 [非空] [SrvProject]      **/
		public final static @type(Long.class)  String spParentId="spParentId";
		/** 家族        **/
		public final static @type(String.class)  String spFamily="spFamily";
		/** 标识        **/
		public final static @type(String.class) @like String spFlag="spFlag";
		/** 项目地址 [非空]       **/
		public final static @type(String.class)  String spUrl="spUrl";
		/** Logo        **/
		public final static @type(String.class)  String spLogo="spLogo";
		/** 项目描述        **/
		public final static @type(String.class)  String spDescript="spDescript";
		/** 优先级        **/
		public final static @type(Integer.class)  String spLevel="spLevel";
		/** and sp_level >= ? */
		public final static @type(Integer.class) String spLevelMin="spLevelMin";
		/** and sp_level <= ? */
		public final static @type(Integer.class) String spLevelMax="spLevelMax";
		/** 扩展权限        **/
		public final static @type(String.class) @like String spLimitExp="spLimitExp";
		/** 项目分组        **/
		public final static @type(String.class)  String spGroup="spGroup";
		/** 流程信息        **/
		public final static @type(String.class) @like String spMind="spMind";
		/** 状态 [非空]   1:有效 0:无效     **/
		public final static @type(Short.class)  String spStatus="spStatus";
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	/** 对象的数据库字段描述 **/
	public static enum C{
		spId("sp_id"),
		spName("sp_name"),
		spParentId("sp_parent_id"),
		spFamily("sp_family"),
		spFlag("sp_flag"),
		spUrl("sp_url"),
		spLogo("sp_logo"),
		spDescript("sp_descript"),
		spLevel("sp_level"),
		spLimitExp("sp_limit_exp"),
		spGroup("sp_group"),
		spMind("sp_mind"),
		spStatus("sp_status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/**
	* 获取项目菜单数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = SrvProject.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = SrvProject.getSrvProject(params);
			else
				value = SrvProject.getSrvProjectList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  SrvProject.where().spId(param).get();
		else if(!Utils.empty(param.toString()))
			value = SrvProject.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		Map map = new HashMap();
		map.put("id",this.getSpId());
		Utils.fms(map,simple?"id":"spId",this.getSpId(),this.getSpId$());
		Utils.fms(map,simple?"name":"spName",this.getSpName(),this.getSpName$());
		Utils.fms(map,simple?"parentId":"spParentId",this.getSpParentId(),this.getSpParentId$());
		Utils.fms(map,simple?"family":"spFamily",this.getSpFamily(),this.getSpFamily$());
		Utils.fms(map,simple?"flag":"spFlag",this.getSpFlag(),this.getSpFlag$());
		Utils.fms(map,simple?"url":"spUrl",this.getSpUrl(),this.getSpUrl$());
		Utils.fms(map,simple?"logo":"spLogo",this.getSpLogo(),this.getSpLogo$());
		Utils.fms(map,simple?"descript":"spDescript",this.getSpDescript(),this.getSpDescript$());
		Utils.fms(map,simple?"level":"spLevel",this.getSpLevel(),this.getSpLevel$());
		Utils.fms(map,simple?"limitExp":"spLimitExp",this.getSpLimitExp(),this.getSpLimitExp$());
		Utils.fms(map,simple?"group":"spGroup",this.getSpGroup(),this.getSpGroup$());
		Utils.fms(map,simple?"mind":"spMind",this.getSpMind(),this.getSpMind$());
		Utils.fms(map,simple?"status":"spStatus",this.getSpStatus(),this.getSpStatus$());
		if(this.suffix!=null)map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
		map.put("spId",this.getSpId());
		map.put("spName",this.getSpName());
		map.put("spParentId",this.getSpParentId());
		map.put("spFamily",this.getSpFamily());
		map.put("spFlag",this.getSpFlag());
		map.put("spUrl",this.getSpUrl());
		map.put("spLogo",this.getSpLogo());
		map.put("spDescript",this.getSpDescript());
		map.put("spLevel",this.getSpLevel());
		map.put("spLimitExp",this.getSpLimitExp());
		map.put("spGroup",this.getSpGroup());
		map.put("spMind",this.getSpMind());
		map.put("spStatus",this.getSpStatus());
		map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static SrvProject fromMap(Map map){
		SrvProject srvProject = new SrvProject();
		srvProject.spId = Utils.parseLong(map.get("spId"));
		srvProject.spName = Utils.parseString(map.get("spName"));
		srvProject.spParentId = Utils.parseLong(map.get("spParentId"));
		srvProject.spFamily = Utils.parseString(map.get("spFamily"));
		srvProject.spFlag = Utils.parseString(map.get("spFlag"));
		srvProject.spUrl = Utils.parseString(map.get("spUrl"));
		srvProject.spLogo = Utils.parseString(map.get("spLogo"));
		srvProject.spDescript = Utils.parseString(map.get("spDescript"));
		srvProject.spLevel = Utils.parseInteger(map.get("spLevel"));
		srvProject.spLimitExp = Utils.parseString(map.get("spLimitExp"));
		srvProject.spGroup = Utils.parseString(map.get("spGroup"));
		srvProject.spMind = Utils.parseString(map.get("spMind"));
		srvProject.spStatus = Utils.parseShort(map.get("spStatus"));
		return srvProject;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(SrvProject old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	public static String getIcon(){
		return "/images/icons/20088256422681277808.png";
	}
	public static String getIconfont(){
		return "icon-gongzuotai";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,SrvProject.M params){
		if(params==null)params=new SrvProject.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/permissions/project.edit.html?";
		if(params.get("spId")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("spId"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/permissions/project.html?1=1";
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.spId(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(SrvProject.ACT act,SrvProject.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",SrvProject.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(SrvProject.ACT act,SrvProject.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",SrvProject.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.ISrvProjectDao getSrvProjectDao(){
		return Utils.getBean("srvProjectDao");
	};
	
}